using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using System;
using System.Collections.Generic;
namespace MicroMsg.Manager
{
	public class SnsGroupMgr
	{
		public static bool IsCustomGroup(SnsTagInfo info)
		{
			if (info == null)
			{
				return false;
			}
			ulong nTagID = info.nTagID;
			return SnsGroupMgr.IsCustomGroup(nTagID);
		}
		public static bool IsCustomGroup(ulong nGroupId)
		{
			return nGroupId >= 6uL;
		}
		public static List<string> GetUsersFromGroup(SnsTagInfo info)
		{
			if (info != null && info.memberList != null)
			{
				return info.memberList.list;
			}
			return null;
		}
		public static List<Contact> GetContactsFromGroup(SnsTagInfo info)
		{
			if (info != null && info.memberList != null && info.memberList.list != null)
			{
				List<Contact> list = new List<Contact>();
				using (List<string>.Enumerator enumerator = info.memberList.list.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						string current = enumerator.get_Current();
						Contact contact = StorageMgr.contact.method_0(current);
						if (contact != null)
						{
							list.Add(contact);
						}
					}
				}
				return list;
			}
			return null;
		}
		public static string GetUseableGroupName()
		{
			string wCGroup_Default_Name = strings.WCGroup_Default_Name;
			List<string> defaultNames = SnsGroupMgr.GetDefaultNames();
			string text = wCGroup_Default_Name;
			int num = 1;
			while (defaultNames.Contains(text))
			{
				text = wCGroup_Default_Name + num;
				num++;
			}
			return text;
		}
		public static List<string> GetAllGroupNames()
		{
			List<SnsTagInfo> list = StorageMgr.snsTag.getList();
			List<string> list2 = new List<string>();
			if (list == null)
			{
				return list2;
			}
			using (List<SnsTagInfo>.Enumerator enumerator = list.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					SnsTagInfo current = enumerator.get_Current();
					if (current != null && current.strTagName != null)
					{
						list2.Add(current.strTagName);
					}
				}
			}
			return list2;
		}
		public static List<string> GetDefaultNames()
		{
			string wCGroup_Default_Name = strings.WCGroup_Default_Name;
			List<SnsTagInfo> list = StorageMgr.snsTag.getList();
			List<string> list2 = new List<string>();
			if (list == null)
			{
				return list2;
			}
			using (List<SnsTagInfo>.Enumerator enumerator = list.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					SnsTagInfo current = enumerator.get_Current();
					if (current != null && current.strTagName != null && current.strTagName.Contains(wCGroup_Default_Name))
					{
						list2.Add(current.strTagName);
					}
				}
			}
			return list2;
		}
		public static bool IsNameUseable(string strName, string strOriginUsableName = "")
		{
			List<string> allGroupNames = SnsGroupMgr.GetAllGroupNames();
			return !allGroupNames.Contains(strName) || strName == strOriginUsableName;
		}
		public static List<ulong> getCustomGroups(SnsGroupList groupList)
		{
			if (groupList != null && groupList.list != null)
			{
				List<ulong> list = new List<ulong>();
				using (List<ulong>.Enumerator enumerator = groupList.list.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						ulong current = enumerator.get_Current();
						if (SnsGroupMgr.IsCustomGroup(current))
						{
							list.Add(current);
						}
					}
				}
				return list;
			}
			return null;
		}
		public static bool IsSetCustomGroup(SnsGroupList groupList)
		{
			if (groupList != null && groupList.list != null)
			{
				bool result;
				using (List<ulong>.Enumerator enumerator = groupList.list.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						ulong current = enumerator.get_Current();
						if (SnsGroupMgr.IsCustomGroup(current))
						{
							result = true;
							return result;
						}
					}
					return false;
				}
				return result;
			}
			return false;
		}
		public static bool IsNeedShowVisiIcon(SnsInfo info)
		{
			return info != null && !(info.strUserName != AccountMgr.strUsrName) && SnsGroupMgr.IsSetCustomGroup(info.groupList);
		}
	}
}
